<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
<div class="easyui-layout" fit="true">
  <div region="center" style="padding:0px;border:0px">
	  <t:datagrid name="consumeList" checkbox="false" fitColumns="true" title="消费记录" 
	  			  actionUrl="studentAccountController.do?studentConsumeLogDatagrid" idField="id" fit="true" queryMode="group">
		  <t:dgCol title="主键"  field="id"  hidden="true"  queryMode="single"  width="120"></t:dgCol>
		  <t:dgCol title="操作日期"  field="txDate" formatter="yyyy-MM-dd"   queryMode="group"  width="120" query="true"></t:dgCol> 
		  <t:dgCol title="学号"  field="stuNo" hidden="true" query="false" queryMode="single"  width="120"></t:dgCol> 
		  <t:dgCol title="姓名"  field="studentName"   query="false" queryMode="single"  width="120"></t:dgCol>  
		  <t:dgCol title="操作"  field="txType"  hidden="true"  queryMode="single"  width="120" ></t:dgCol>
		  <t:dgCol title="操作"  field="txType.name"  hidden="false"  queryMode="single"  width="120" query="false"></t:dgCol>
		  <t:dgCol title="交易金额"  field="txAmount"    queryMode="single"  width="100"></t:dgCol>
		  <t:dgCol title="余额"  field="afterBalance"    queryMode="single"  width="100"></t:dgCol>
		  <t:dgCol title="操作人姓名"  field="operateUserName"    queryMode="single" query="false"  width="100"></t:dgCol> 
		  
		  <t:dgToolBar title="excelOutput" icon="icon-putout" funname="ExportXls"></t:dgToolBar>
	  </t:datagrid>
  </div>
</div>
<script type="text/javascript"> 
	$(document).ready(function(){
		//给时间控件加上样式
		$("input[name='txDate_begin']").attr("class","Wdate").click(function(){WdatePicker({dateFmt:'yyyy-MM-dd'});});
		$("input[name='txDate_end']").attr("class","Wdate").click(function(){WdatePicker({dateFmt:'yyyy-MM-dd'});});
		
		initBalance();
	});

	//导出
	function ExportXls() {
		JeecgExcelExport("studentAccountController.do?exportConsumeXls","consumeList");
	} 
	
	function initBalance(){
		var isAdmin = ${isAdmin};
		if(isAdmin)  return;
		$.ajax({
			url : 'studentAccountController.do?balance',
			type : 'post', 
			cache : false,
			success : function(data) {
				var d = $.parseJSON(data);
				var studentAccount = d.obj;
				$("form[id='consumeListForm']").append("<span style='font-size: 17px; color: red; float: right; margin-right: 10px'> 当前余额："+ (studentAccount==null?0:studentAccount.balance) +"</span>");
			}
		});
	}
</script>